<template>
    <div class="content">
        <div class="flex-start">
            <div class="shuxing"></div>
            <div class="page-title">联系方式</div>
        </div>
        <div class="justify-between m-t-17">
            <div class="flex-start">
                <div class="label">
                    <span class="red">*</span>
                    <span>旧密码:</span>
                </div>
                <input type="password" class="cascaderClass" v-model="form.old_password"></input>
            </div>
        </div>
        <div class="justify-between m-t-17">
            <div class="flex-start">
                <div  class="label">新密码：</div>
                <input type="password" class="cascaderClass" v-model="form.password"></input>
            </div>
        </div>
        <div class="justify-between m-t-17">
            <div class="flex-start">
                <div  class="label">
                    重复新密码：
                </div>
                <input type="password"  class="cascaderClass" v-model="form.password_confirm"></input>
            </div>
        </div>

        <div class="flex-start m-t-24">
            <div class="label">
                <span> </span>
            </div>
            <div class="flex-start">
                <div class="btnCancel">取消</div>
                <div class="btnSave" @click="saveData">保存</div>
            </div>
        </div>
    </div>
</template>

<script>
import { mapState } from "vuex";
import axios from "axios";

export default {
    computed: {
        ...mapState([
            "userInfo",
            'token'
        ]),
    },
    data() {
        return {
            fileList: [],
            options: [],
            form: {
                old_password: '',
                password: "",
                password_confirm: '',
            },
        }
    },
    watch: {
    },
    created() {
        this.form = this.userInfo;
    },
    methods: {
        saveData() {
            if (!this.form.old_password) {
              alertErr('旧密码不能为空');
              return;
            }
            if (!this.form.password) {
                alertErr('新密码不能为空');
                return;
            }
            if (!this.form.password_confirm) {
                alertErr('重复新密码不能为空');
                return;
            }
            if (this.form.password!==this.form.password_confirm ) {
                alertErr('新密码和重复新密码不一样');
                return;
            }
            this.$httpApi("/api/updatePassword", {
                old_password: this.form.old_password,
                password: this.form.password,
                password_confirm: this.form.password_confirm,
                token: this.token
            }, "post").then(res => {
                if (res.code == 200) {
                    this.$store.dispatch("getUserloginedInfo");
                    alertSucc('保存成功');
                    this.form = {
                        old_password: '',
                        password: "",
                        password_confirm: '',
                    };
                } else {
                    alertErr(res.msg);
                }
            })
        },
    }
}
</script>

<style scoped lang="less">
.content {
    padding-top: 32px;
    padding-left: 32px;
    padding-bottom: 26px;
    padding-right: 94px;
    background: #FFFFFF;

    .shuxing {
        width: 6px;
        height: 18px;
        background: #31A41B;
        border-radius: 3px 3px 3px 3px;
    }

    .flex-start {
        display: flex;
        align-items: center;
    }

    .page-title {
        font-family: PingFang SC, PingFang SC;
        font-weight: 500;
        font-size: 16px;
        color: #333333;
        margin-left: 10px;
    }

    .m-t-24 {
        margin-top: 24px;
    }

    .label {
        flex-basis: 144px;
        flex-grow: 0;
        /* 禁止放大 */
        flex-shrink: 0;
        /* 禁止缩小 */
        text-align: right;
        font-weight: 400;
        font-size: 14px;
        color: #333333;
        margin-right: 10px;
    }

    .companylogo {
        width: 120px;
        height: 74px;
    }

    .renewval {
        width: 100px;
        height: 36px;
        background: #EAF6E8;
        border: 1px solid #31A41B;
        font-weight: bold;
        font-size: 14px;
        color: #31A41B;
        text-align: center;
        line-height: 36px;
        border-radius: 20px;
        margin-top: 11px;
    }

    .name {
        text-align: right;
        font-weight: 400;
        font-size: 14px;
        color: #333333;
    }

    .red {
        color: #E5020D;
    }

    .m-l-27 {
        margin-left: 27px;
    }

    .m-l-14 {
        margin-left: 14px;
    }

    .justify-between {
        display: flex;
        justify-content: space-between;
        flex-grow: 1;
    }

    .m-t-17 {
        margin-top: 17px;
    }

    .cascaderClass {
        width: 400px;

        .el-input__inner {
            background: #FAFAFA;
        }
    }

    .btnCancel {
        width: 133px;
        height: 40px;
        background: #F5F5F5;
        border-radius: 4px 4px 4px 4px;
        border: 1px solid #D7D7D7;
        font-weight: 400;
        font-size: 14px;
        color: #666666;
        text-align: center;
        line-height: 40px;
        cursor: pointer;
    }

    .btnSave {
        width: 133px;
        height: 40px;
        background: #31A41B;
        border-radius: 4px 4px 4px 4px;
        border: 1px solid rgba(0, 0, 0, 0);
        font-weight: 400;
        font-size: 14px;
        color: #FFFFFF;
        cursor: pointer;
        text-align: center;
        line-height: 40px;
        margin-left: 12px;
    }

    .tips {
        font-weight: 400;
        font-size: 12px;
        color: #999999;
        line-height: 24px;
    }

    .fileIcon {
        width: 20px;
        height: 20px;
        margin-right: 6px;
    }

    .gouxuanIcon {
        width: 12px;
        height: 12px;
    }

    .flex-space-between {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .uploadRight {
        display: flex;
        height: 120px;
        align-items: flex-end;
        flex-direction: column;
        justify-content: flex-end;
    }
}

/deep/.el-upload-dragger {
    background: #FAFAFA;
    width: 200px;
    height: 120px;

    .el-icon-upload {
        font-size: 48px;
        margin: 0px;
        margin-top: 16px;
        margin-bottom: 16px;
    }

    .el-upload__text {
        color: #A2A2A2;
    }

    em {
        color: #A2A2A2;
    }
}

/deep/.el-upload-dragger:hover {
    border: 1px solid #FAFAFA;
}

input {
    flex: 2;
    height: 100%;
    padding-left: 16px;
    font-size: 14px;
    color: #000;
    background: #FAFAFA;
    border-radius: 4px 4px 4px 4px;
    border: 1px solid #E6E5E5;
    height: 40px;
    flex-basis: 260px;
    flex-grow: 0;
    flex-shrink: 0;

    &::-webkit-input-placeholder {
        font-size: 14px;
        font-family: Microsoft YaHei-Regular, Microsoft YaHei;
        font-weight: 400;
        color: #d7d7d7;
    }
}

textarea {
    flex: 2;
    height: 100%;
    padding: 16px;
    font-size: 14px;
    color: #000;
    background: #FAFAFA;
    border-radius: 4px 4px 4px 4px;
    border: 1px solid #E6E5E5;
    height: 160px;

    &::-webkit-input-placeholder {
        font-size: 14px;
        font-family: Microsoft YaHei-Regular, Microsoft YaHei;
        font-weight: 400;
        color: #d7d7d7;
    }
}

textarea:focus {
    outline: none;
    border: 1px solid #E6E5E5;
}

/deep/.el-input__inner {
    background: #FAFAFA;
}
</style>